export function delay(fun: () => void, ms: number) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(fun());
    }, ms);
  });
}

export function sleep(time: number) {
  return new Promise((resolve) => {
    const timeStamp = new Date().getTime();
    const endTime = timeStamp + time;
    while (true) {
      if (new Date().getTime() > endTime) {
        resolve(true);
        return;
      }
    }
  });
}
